package com.NyCloud.controller;


import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import com.NyCloud.entity.MarketInfo;
import com.NyCloud.service.IMarketInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者
 * @since 2024-09-23
 */
@RestController
@RequestMapping("/market-info")
@Api(tags = "市场信息")
@CrossOrigin
public class MarketInfoController {

    @Autowired
    private IMarketInfoService marketInfoService;


    @GetMapping("/list")
    @ApiOperation("所有")
    public List<MarketInfo> getMarketInfoList() {
        return marketInfoService.list();
    }

    @PostMapping
    @ApiOperation("新增")
    public SaResult addMarketInfo(@RequestBody MarketInfo marketInfo) {
        marketInfo.setCreateBy(StpUtil.getLoginIdAsInt());
        marketInfo.setCreateTime(LocalDateTime.now());
        marketInfoService.save(marketInfo);
        return SaResult.ok();
    }

}
